<template>
  <el-dialog :title="title" :visible.sync="dialogVisible" :close-on-click-modal="false" width="850px">
    <div class="form-box">
      <el-descriptions title="账号信息" :column="1" border :labelStyle="{width:'100px'}">
        <el-descriptions-item label="游戏">{{huishouObj.type}}</el-descriptions-item>
        <el-descriptions-item label="游戏账号">{{huishouObj.account}}</el-descriptions-item>
        <el-descriptions-item label="区服">{{huishouObj.region}}</el-descriptions-item>
        <el-descriptions-item label="简介">{{huishouObj.des}}</el-descriptions-item>

      </el-descriptions>
      <el-table border :data="list" style="width: 100%;">
        <!-- <el-table-column prop="id" label="编号" width="55">
        </el-table-column> -->
        <!-- <el-table-column prop="id" label="回收ID" width="90">
        </el-table-column>
        <el-table-column prop="account" label="游戏账号" >
        </el-table-column> -->
        <el-table-column prop="bprice" label="报价">
        </el-table-column>
        <el-table-column prop="createName" label="报价人">
        </el-table-column>
        <el-table-column prop="createTime" label="报价时间">
        </el-table-column>
        <el-table-column label="状态" width="120">
          <template slot-scope="scope">
            <span v-if="scope.row.status==1">已接受</span>
            <span v-if="scope.row.status==2">已拒绝</span>
            <span v-if="scope.row.status==3">已完成</span>
            <el-button type="text" v-if="scope.row.status==0" @click="jieshou(scope.row)">接受报价</el-button>
          </template>
        </el-table-column>

      </el-table>

    </div>
  </el-dialog>
</template>

<script>
import onSelfApi from "@/api/retrieveManage/onSelf.js";
export default {
  name: "",
  data() {
    return {
      dialogVisible: false,
      loading: false,
      title: "报价列表",
      list: [],
      total: 0,

      // 表单参数
      form: {},
      rules: {},
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        backId: "",
        selectType: "allQue",
      },
      huishouObj: {},
    };
  },
  created() {},
  methods: {
    // 打开弹窗
    open(data) {
      this.dialogVisible = true;
      this.queryParams = {
        pageNum: 1,
        pageSize: 20,
        backId: "",
        selectType: "allQue",
      };
      this.queryParams.backId = data.id;
      this.getList();
    },
    getList() {
      onSelfApi.getMyBprice(this.queryParams.backId).then((res) => {
        this.list = res.data.rlist;
        this.huishouObj = res.data.back;
      });
    },
    jieshou(row) {
      this.$confirm(
        "接受报价后将不能接受其他回收商的报价，是否继续？",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          let obj = {
            supplyUserId: row.createId,
            id: row.backId,
          };
          onSelfApi.jieshou(obj).then((res) => {
            this.$alert(res.msg);
            this.getList();
          });
        })
        .catch(() => {});
    },
    close() {
      this.dialogVisible = false;
    },
    // 每页条数改变
    handleSizeChange(val) {
      this.queryParams.pageSize = val;
      this.getList();
    },
    // 页码改变
    handleCurrentChange(val) {
      this.queryParams.pageNum = val;
      this.getList();
    },
  },
};
</script>
<style scoped lang="css">
.center {
  text-align: center;
}

.form-box {
  width: 100%;
  height: calc(100vh - 20vh - 200px);
  overflow-y: auto;
  /* padding-top: 20px; */
}

.img-box {
  width: 700px;
}
</style>
